package com.qu.waibao;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.util.Log;

import com.baidu.location.BDLocation;
import com.qu.waibao.baidu.LocationUtils;
import com.qu.waibao.base.BaseActivity;
import com.qu.waibao.home.nav.NavFragment;
import com.qu.waibao.home.nav.NavigationButton;
import com.qu.waibao.interf.OnTabReselectListener;
import com.qu.waibao.utils.ToastUtil;

public class MainActivity extends BaseActivity implements NavFragment.OnNavigationReselectListener,
        LocationUtils.ILocateDelegate {
    private NavFragment mNavBar;

    @Override
    protected int getContentView() {
        return R.layout.activity_main;
    }

    @Override
    protected void initWidget() {
        LocationUtils.locateDelegateArrayList.add(this);
        LocationUtils.startLocation();
        super.initWidget();
        FragmentManager manager = getSupportFragmentManager();
        mNavBar = ((NavFragment) manager.findFragmentById(R.id.frg_nav));
        mNavBar.setup(this, manager, R.id.fl_container, this);

    }

    @Override
    protected void initData() {
        super.initData();
    }

    @Override
    public void onReselect(NavigationButton navigationButton) {
        Fragment fragment = navigationButton.getFragment();
        if (fragment != null
                && fragment instanceof OnTabReselectListener) {
            OnTabReselectListener listener = (OnTabReselectListener) fragment;
            listener.onTabReselect();
        }
    }
    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        LocationUtils.locateDelegateArrayList.remove(this);
    }

    @Override
    public void onLocateSuccess(BDLocation location) {

    }

    @Override
    public void onLocateFailed() {

    }
}
